/* Global defines */

/* Project defines */
#include "xelix_proto.h"
#include "trace.h"
#include "tools.h"

void* memcpy_inv (void* output, const void* input, int sz) {
	int i,j;
	char *d = (char *)output, *s = (char *)input;
	for (i=0,j=sz-1;i<sz;i++,j--) d[j] = s[i];
	return output;
}

void xelix_proto_struct_print(p_xelix_proto_t structure){
	int i;
	/* print header */
	TRACE_INFO("[%s]->0x%04X", "Header", structure->msg_header);
	/* print msg type */
	TRACE_INFO("[%s]->0x%04X", "Type", structure->msg_type);
	/* print msg sequence numbet */
	TRACE_INFO("[%s]->0x%04X", "Sequence", structure->msg_seq_num);
	/* print msg size */
	TRACE_INFO("[%s]->0x%04X", "Size", structure->msg_sz);
	/* print msg content */
	TRACE(APP_TRACE_MASK_INFO, "[%s_INFO]->[%s]->", __FUNCTION__, "Content");
	for(i = 0; i < structure->msg_sz; i++){
		TRACE(APP_TRACE_MASK_INFO,"0x%02X ", ((uint8_t *)(structure->msg_content))[i]);
	}
	TRACE(APP_TRACE_MASK_INFO,"|:%d\r\n", __LINE__);
	/* print crc16 */
	TRACE_INFO("[%s]->0x%04X", "Crc16", structure->crc16);
}
